#include<iostream>
using namespace std;
const int maxn = 100006;
int n, S;
int a[maxn];
int solve() {
  cin >> n >> S;
  for(int i=0; i<n; ++i) {
    cin >> a[i];
  }
  int res = n + 1;
  int s = 0, t = 0, sum = 0;
  for (;;) {
    while (t < n && sum < S) {
      sum += a[t++];
    }
    if (sum < S) break;
    res = min(res, t - s);
    sum -= a[s++];
  }
  if (res > n) {
    res = 0;
  }
  cout << res << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  int tc; cin>>tc;
  for (int t = 1; t <= tc; t++) {
    // cout << "Case #" << t << ": "
    solve();
  }
  return 0;
}
